package fr.afcepf.iziticket.beans;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import fr.afcepf.iziticket.dao.interfaces.DAOSpectacle;
import fr.afcepf.iziticket.entities.Spectacle;

@ManagedBean(name="mbHomeSpectacles")
@SessionScoped
public class HomeSpectacleManagedBean {
	private List<Spectacle> spectacles = new ArrayList<Spectacle>();

	public List<Spectacle> getSpectacles() {
		if(spectacles.size() == 0){
			DAOSpectacle daoSpectacle = (DAOSpectacle) MainManagedBean.getContext().getBean("daoSpectacle");
			spectacles = daoSpectacle.getAll();
			Collections.reverse(spectacles);
		}
		System.out.println("taille top spectacles : " +  spectacles.size());
		return this.spectacles;
	}

	public void setSpectacles(List<Spectacle> spectacles) {
		this.spectacles = spectacles;
	}

	/**
	 * 
	 */
	public HomeSpectacleManagedBean() {
		super();
	}
	
}
